<template>
	<u-mask :show="shareModel" @click="closeMask">
		<view class="content">
			<u-image @click="jumpLink" width="80%" class="poster" :src="shareImg" mode="widthFix" border-radius="20" :lazy-load="true"></u-image>
		</view>
	</u-mask>
</template>

<script>
	import shareJS from "@/utils/share.js"

	export default {
		name: "adMask",
		mixins: [shareJS],
		data() {
			return {
				shareModel: false,
			}
		},

		onLoad() {
			uni.showShareMenu({
				title: '哆嗯商城',
				content: '好物分享',
				path: '/pages/tabBar/home'
			})
		},
		methods: {
			closeMask() {
				this.shareModel = false
				this.$emit('onCloseMask')
			},
			async jumpLink() {
				const data = await this.getAdHomeData();
				const jumpLink = await data.data.jump_link;
				if(jumpLink != null && jumpLink != ""){
					uni.navigateTo({
						url: jumpLink,
					  });
				}
			},
			// 获取广告数据
			getAdHomeData() {
				return new Promise((resolve, reject) => {
					this.$http.getAdHomeData().then(res => {
						if (res.status === 200) {
							resolve(res.data)
						} else {
							reject(res)
						}
					})
			
				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.content{
		top: 50%;
		left: 50%;
		width: 100%;
		position: fixed;
		transform: translate(-50%, -50%);
	}
	.poster {
		display: flex;
		justify-content: center;

	}

</style>
